{% extends 'AdminBundle::layout.html.twig' %}

    {% block title %}文件分类{% endblock %}

    {% block css %}{% endblock %}



{% block top %}
    {#{{ dump() }}#}
    {{ parent() }}
{% endblock %}


    {% block left_body_top %}
        {{ parent() }}
    {% endblock %}


    {% block left_body %}
        {{ parent() }}
    {% endblock %}

    {% block right_body %}
    <div class="page-header">
        <div class="page-right-top">
            <div class="right-top">
                <span class="right-title">文件管理</span>
            </div>
        </div>
        <div class="main-content">
            <div class="main-top">
                <div class="index-list file-m1">
                    <div class="index-total">已发送文件消息总数</div>
                    <div class="index-totalNum">
                        <span>{{ data.all_count }}</span>件
                    </div>
                </div>
                <div class="index-list file-m2">
                    <div class="index-total" style="padding-top: 13px;">本月发布文件消息总数</div>
                    <div class="index-totalNum">
                        <span>{{ data.month_count }}</span>件
                    </div>
                </div>
                <div class="index-list file-m3">
                    <div class="index-total">今日发送文件消息数</div>
                    <div class="index-totalNum">
                        <span>{{ data.day_count }}</span>件
                    </div>
                </div>
            </div>



            <div class="mes-content">

                <div class="main-mes-top">

                    <button class="lang-btn fl"  type="button">新建文件夹</button>
                    <div class="clearfix"></div>
                </div>

                <div class="main-mes-content" >
                    <div class="file-list-box">




                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="pop-status opacity"></div>

    <!--新建文件夹信息-->
    <div class="pop-first pop-classify" style="display: none;">
        <div class="pop-title">添加文件夹
            <span class="close close-icon"></span>
        </div>
        <form id="classSubmit">
            <div style="padding: 30px;">
                <div class="com-left fl" style="width: 86px;">文件夹名称</div>
                <input type="text" class="com-select com-is-name" placeholder="请输入文件夹名称" style="width: 350px;padding: 0 15px;">

                <div class="add-mem-box" style="margin:30px 0;overflow: hidden;">
                    <div class="com-left fl"></div>
                    <div class="acc-opera-btn fl mem-btn classify-btn">保存</div>
                    <div class="acc-opera-btn fl mem-cancel">取消</div>
                </div>
            </div>
        </form>
    </div>

    {% endblock %}


{% block box %}
{% endblock %}


{% block javascript %}
<script type="text/javascript">
    $(function () {

        SidebarHighlighting('6');

        // 点击查询
        $('.mes-query-btn').on('click', function() {
            var keyword = $("input[name='keyword']").val();

            if ($.trim(keyword) == '') {
                popStatus(2, '请输入关键字', 1,'', true);
                return;
            }
        });

        //点击取消
        $('.mem-cancel, .close-icon').on('click', function() {
            ComMesClose();
        });

        // 弹框显示函数
        function ComMesClose() {
            $('.pop-status').hide();
            $('.pop-second').hide();
            $('.pop-first').hide();
        }

        function ComMesOpen() {
            $('.pop-status').show();
        }


        // 点击新建文件夹
        $('.lang-btn').on('click', function() {
            ComMesOpen();
            $('.pop-first').show();
        });

        // 添加文件分类
        $('.classify-btn').on('click', function () {
            var title = $(".com-is-name").val();

            if ($.trim(title) == '') {
                popStatus(2, '请输入名称', 1, '', true);
                return;
            }

            $.post("{{ path('api_admin_add_file_category') }}",{title:title},function(data){
                console.log(data);
                if(data.errorCode == 0){
                    var status = 1;
                } else {
                    var status = 2;
                }
                popStatus(status, data.message, 1, '', true);
            })

            $(".com-is-name").val('');

            ComMesClose();

            //重新获取文件分类
            $(".file-list-box").empty();
            getFileCategory();
        });

        // 获取文件分类
        function getFileCategory(){
            $.post("{{ path('api_admin_get_file_category') }}",{},function(data){
                console.log(data);
                var item = data.data.info;
                for(var i in item){

                    var html = '';
                    var img_src = "{{ asset('assets/img/icon/folder.png') }}";

                    var info_url = "{{ path('file_list',{id:'765964743435'}) }}".replace("765964743435",item[i].id);
                    html += '<a class="file-item fl" href="'+ info_url +'">';
                    html += '<img src="'+ img_src +'" class="folder" alt="">';
                    html += '<span class="folder-text a-line">'+ item[i].name +'</span>';
                    html += '</a>';

                    $(".file-list-box").append(html);

                }

            })
        }

        getFileCategory();

    })
</script>
{% endblock %}